<?php
/**
 * Created by PhpStorm.
 * User: 明哲
 * Date: 2016/4/29
 * Time: 11:07
 */
include('../../config.php');

$current_time = date('Y-m-d H:i:s', time());
$action = $_GET['action'];
$type = $_GET['type'];
$page = $_GET['page'];
$number = 10;
$min = $page * $number - $number;

$pipeName = $_GET['pipeName'];
$pipeType = $_GET['pipeType'];
$unitPrice = $_GET['unitPrice'];
$clearCycle = $_GET['clearCycle'];
$productName = $_GET['productName'];
$pipeUsername =$_GET['pipeUsername'];
$pipePass = $_GET['pipePass'];
$companyName = $_GET['companyName'];
$companyAddress = $_GET['companyAddress'];
$contactName = $_GET['contactName'];
$contactTel = $_GET['contactTel'];

$del_id = $_GET['id'];

switch ($action) {
    default :
        $rows = $mysql->query("select * from `pipe` order by id  limit {$min},{$number}");
        if ($rows) {
            $rows = json_encode($rows);
            echo $rows;
        } else {
            echo 0;
        }
        break;
    case 'add' :
        $rows = $mysql->query("insert into `pipe` VALUES(null,'{$pipeName}','{$pipeType}','{$unitPrice}','{$clearCycle}','{$productName}','{$pipeUsername}','{$pipePass}','{$companyName}','{$companyAddress}','{$contactName}','{$contactTel}')");
        echo 1;
        break;
    case 'del' :
        $rows = $mysql->query("delete from `pipe` where `id`='{$del_id}'");
        echo 1;
        break;
    case 'edit' :
        break;
}